//
// Created by hsj on 2022/2/23.
//

#include "stack_template.h"
namespace t_class_template_test{

    //测试使用
    void test(){
//      const char *arr[] = {"123","456"};
//      const char **p2arr = arr;
//      cout<<*(p2arr+1)<<endl;
//      const char *arr2[][2] = {{"123","456"},{"789","111213"}};
//      cout<<*(*(arr2+0)+1)<<endl;

      //显示实例化
      Stack<string> st;
      char ch;
      string po;
      cout<<"Pleaes enter A to add a purchase order,"<<endl;
      cout<<"P to process a PO,or Q to quit."<<endl;

        while (cin >> ch && std::toupper(ch) != 'Q'){
            //清除后面的，直到回车
            while (cin.get() != '\n'){
                continue;
            }
            //不是字母的话，下一轮循环
            if (!std::isalpha(ch)){
                cout<<'\a';
                continue;
            }

            switch (ch) {
                case'A':
                case'a':
                    cout<<"Enter a PO number to add:";
                    cin>>po;
                    if(st.isFull()){
                        cout<<"statck have full.";
                    }
                    else{
                        st.push(po);
                    }
                    break;
                case'P':
                case'p':
                    if (st.isEmpty()){
                        cout<<"statck already empty.";
                    }
                    else{
                        st.pop(po);
                        cout<<"PO#:"<<po<<" popped."<<endl;
                    }
                    break;
            }
            cout<<"Pleaes enter A to add a purchase order,"<<endl;
            cout<<"P to process a PO,or Q to quit."<<endl;
        }

        cout<<"Done,bye."<<endl;
    }

}